<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var p=new Promise(function(resolve,reject){
            setTimeout(function(){
                var num=Math.random();
                if(num>0.5){
                    resolve(num);
                }else{
                    reject(num);
                }
            },2000)
        })
        p.then(function(flag){
            console.log('随机数值大于0.5',flag)
        },function(e){
            console.log('随机数值小于等于于0.5',e)
        })
        console.log(p);
    </script>
</head>
<body>
    
</body>
</html>